package com.xzh.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xzh.model.Students;
import com.xzh.model.Teachers;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;
import java.util.Map;

@Mapper
public interface TeachersMapper extends BaseMapper<Teachers> {
    default Page<Teachers> selectAll(Page<Teachers> page, Teachers teachers){
        LambdaQueryWrapper<Teachers> qw = Wrappers.lambdaQuery(teachers);
        return selectPage(page, qw);
    }

    default List<Map<String, Object>> statistics(){
        QueryWrapper<Teachers> qw = new QueryWrapper<>();
        qw.select("title", "COUNT(*) as count")
                .groupBy("title");
        return selectMaps(qw);
    }
}
